home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20041116-20060924
/
000363_fdc@columbia.edu_Wed Jun 21 12:26:32 2006.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
3KB
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Assigning output from LINEOUT to a variable
Date: 21 Jun 2006 16:26:26 GMT
Organization: Columbia University
Lines: 67
Message-ID: <slrne9ispi.jaj.fdc@sesame.cc.columbia.edu>
References: <1150811644.629253.47720@r2g2000cwb.googlegroups.com> <slrne9g25a.h41.fdc@sesame.cc.columbia.edu> <1150816457.938186.136820@r2g2000cwb.googlegroups.com>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1150907186 24891 128.59.59.56 (21 Jun 2006 16:26:26 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 21 Jun 2006 16:26:26 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15620
On 2006-06-20, toastyboy@googlemail.com <toastyboy@googlemail.com> wrote:
: Regarding parsing the output, here is what I would simply expect to see
: either a 1 or a 0 (depending on the state of the input) followed by a #
: on a new line.
:
: (The # is the command prompt on this device if you like)
:
: See the below extract from an interactive session:
:
: #
: #I1
: 1
: #I2
: 1
: #I3
: 1
: #I4
: 0
: #
:
: What I want is either to set the 0 or 1 as a variable and then based on
: this write out a file with the 0 or 1 in it, or (better still) write
: the 0 or 1 out to a file directly.
:
You want to send a command to this device, get back a single-character
response, and write the response to a file. This is seemingly
straightforward, but there's a bit more to it, because maybe the device echoes
what you send, and since the single-character responses really come with some
other stuff, such as carriage returns and linefeeds. What do you want to go
into your file -- a single digit, or the digit followed by carriage return
and/or linfeed?
Let's say you want to store <digit><CR><LF>. Then the above sequence
would be programmed something like this:
clear input ; start with a clean INPUT buffer
output \13 ; send a carriage return (\13) to make a prompt appear
input 5 \# ; wait 5 sec for the '#' prompt
if fail stop 1 ; make sure we got it
output I1\13 ; Send "I1" and a carriage return
; Let's assume the devices echoes "I1<CR><LF>"
input 5 I1\13\10 ; Absorb the echo
if fail ... ; Do something if the echo does not appear
clear input ; clear the input buffer again
input 5 \10 ; Input everything up to a linefeed
if fail ...
; At this point \v(input) should contain the resonse.
; Now you can write it to a file.
fopen /write \%c somefilename
if fail ...
fwrite /line \%c \ftrim(\v(input))
fclose \%c
and so on for I2, I3, and I4. I didn't show what to do on failure,
that's up to you. Maybe there is some corrective action you can take.
You can loop and try again, whatever. The statement:
fwrite /line \%c \ftrim(\v(input))
trims the CRLF from the response, and then writes it to disk in native
format for a line, which is not necesarily text terminated by CRLF.
- Frank